package com.gadgets.busi.bm03.controller;

import com.gadgets.busi.bm03.common.dto.SqlGeneratorDTO;
import com.gadgets.busi.bm03.fegin.ISqlGeneratorSqlController;
import com.gadgets.framework.annotation.RoleAuthCheck;
import com.gadgets.framework.common.dto.HttpBaseResp;
import com.gadgets.framework.common.util.FeginRequestMapUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;

/**
 * 功能说明：
 *
 * @author Unclexiu
 * @version V202101.00.000
 * @data 2022-09-15
 * 修改记录：  修改日期          修改人员    修改说明
 * 2022-09-15  xiujunqing   创建文件
 */
@RestController
@RequestMapping(method = {RequestMethod.POST, RequestMethod.GET},value = "/bm03")
public class GadgetsBm03Fork {

	@Autowired
	private ISqlGeneratorSqlController sqlGeneratorSqlController;

	/**
	 * SQL生成器
	 * @param request           网络请求信息
	 * @param response          网络应答信息
	 * @param generatorDTO      SQL生成要素信息
	 * @return                  受理结果
	 */
	@RoleAuthCheck
	@RequestMapping(method = {org.springframework.web.bind.annotation.RequestMethod.POST,org.springframework.web.bind.annotation.RequestMethod.GET},value = "mysqlBuild.do")
	@SuppressWarnings("rawtypes")
	public HttpBaseResp sqlGeneratorForMysql(HttpServletRequest request, HttpServletResponse response, SqlGeneratorDTO generatorDTO){
		HashMap<String, Object> requestParam = new HashMap<>();
		FeginRequestMapUtil.parseRequestParam(generatorDTO, requestParam);
		return sqlGeneratorSqlController.sqlGeneratorForMySql(requestParam);
	}

	/**
	 * SQL生成器
	 * @param request           网络请求信息
	 * @param response          网络应答信息
	 * @param generatorDTO      SQL生成要素信息
	 * @return                  受理结果
	 */
	@RoleAuthCheck
	@RequestMapping(method = {org.springframework.web.bind.annotation.RequestMethod.POST,org.springframework.web.bind.annotation.RequestMethod.GET},value = "mysqlBuild.do")
	@SuppressWarnings("rawtypes")
	public HttpBaseResp sqlGeneratorForOracle(HttpServletRequest request, HttpServletResponse response, SqlGeneratorDTO generatorDTO){
		HashMap<String, Object> requestParam = new HashMap<>();
		FeginRequestMapUtil.parseRequestParam(generatorDTO, requestParam);
		return sqlGeneratorSqlController.sqlGeneratorForOracle(requestParam);
	}

}
